<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>麻利分期</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../static/css/reset.min.css" />
		<link rel="stylesheet" type="text/css" href="../static/css/qian_load.css" />
	</head>

	<body>
		<div class="body">
			<img src="../static/img/bg_top.png" class="bg_top" />
			<div class="main">
				<img src="../static/img/mali_logo.png?v=2" />
				<p>麻利分期</p>
				<div class="guide">
					<button onclick="downloadAndroid()" style="background: #FFD207;">安卓版下载</button>
					<span onclick="window.location.href = 'guidea.html'">华为手机安装说明</span>
				</div>
				<div class="guide">
					<button onclick="downloadIos()" style="background: #FFD207;">苹果版下载</button>
					<span onclick="window.location.href = 'guide.html'">苹果手机安装指南</span>
				</div>
			</div>
			<img src="../static/img/bg_bottom.png" class="bg_bottom" />
		</div>
		<div class="wechat" onclick="wechat()">
			<img src="../static/img/wechat.png" alt="weixin" />
		</div>
		<div class="text"></div>
	</body>
	<script src="../static/js/common.js"></script>
	<script type="text/javascript" src="../static/js/jquery-2.1.4.min.js"></script>
	<script src="https://s19.cnzz.com/z_stat.php?id=1275767378&web_id=1275767378" language="JavaScript"></script>
	<script>
		var _czc = _czc || [];
		_czc.push(["_setAccount", "1275767378"]);

		function push(alias, action, clientType, origin) {
			try {
				_czc.push(﻿["_trackEvent", clientType + "-" + origin, action]);
			} catch(e) {
				//TODO handle the exception
			}
		}
	</script>
	<script>
		var path = window.location.pathname;
		var start = path.lastIndexOf("\/");
		var end = path.lastIndexOf(".");
		var filename = path.substring(start + 1, end);
		var alias = filename.split("_")[1];
		var domain = apiDomain();
		var clientType = getClientType();
		var apk_url = "";
		var makert_url = "";

		var origin_id = GetQueryString("origin");
		origin_id = origin_id ? origin_id : clientType;

		try {
			$.ajax({
				type: "post",
				url: domain + "check_version",
				dataType: "json",
				data: {
					alias: alias,
					type: clientType,
					version: "1.0.0"
				},
				success: function(data) {
					if(data.status == 2000) {
						apk_url = data.data.versionUrl;
						makert_url = data.data.appMarket;
					}
				}
			});
		} catch(e) {
			//TODO handle the exception
		}

		function downloadAndroid() {
			var wechat = isWeiXin();
			var ua = navigator.userAgent.toLowerCase();
			if(/android/.test(ua)) {
				if(wechat) {
					$(".wechat").stop().show();
					$(".body").stop().hide();
					return;
				}
				push(alias, "下载", clientType, origin_id);
				if(makert_url) {
					window.location.href = makert_url;
					return;
				}
				if(apk_url) {
					window.location.href = apk_url;
					return;
				}
			} else {
				block("请点击苹果版下载")
			}
		}

		function downloadIos() {
			var ua = navigator.userAgent.toLowerCase();
			if(/iphone|ipad|ipod/.test(ua)) {
				push(alias, "下载", clientType, origin_id);
				if(makert_url) {
					window.location.href = makert_url;
					return;
				}
				if(apk_url) {
					window.location.href = apk_url;
					return;
				}
			} else {
				block("请点击安卓版下载")
			}
		}

		function block(text) {
			$(".text").stop().html(text).show();
			setTimeout(function() {
				$(".text").stop().hide();
			}, 1500)
		}

		function wechat() {
			$(".wechat").stop().hide();
			$(".body").stop().show();
		}
	</script>

</html>